package com.eascs;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONObject;
import com.eascs.account.api.constants.enums.SourceType;
import com.eascs.account.api.constants.enums.TradeType;
import com.eascs.account.api.vo.TradeDetailVO;
import com.eascs.account.api.vo.TradeParamsVO;
import com.eascs.admin.common.utils.AccountConstants;
import com.eascs.admin.o2o.internal.entity.LoanapplyExpand;
import com.eascs.admin.o2o.internal.util.StatusContexts;
import com.eascs.admin.o2o.loanAccount.dao.AccountLogDao;
import com.eascs.admin.o2o.loanAccount.entity.AccountLog;
import com.eascs.admin.o2o.loanAccount.entity.O2oLoanapplyAccountEntity;
import com.eascs.common.util.StringUtil;
import com.eascs.common.util.UuidUtil;
import com.eascs.crm.common.custnew.entity.CustomerEntity;
import com.eascs.workflow.common.vo.ModelResult;


public class testmain {
	
	@Autowired
	static
	AccountLogDao accountLogDao;
	
	
	 public static void readTxtFile(String filePath){
	        try {
	                String encoding="GBK";
	                System.out.println("开始");
	                File file=new File(filePath);
	                if(file.isFile() && file.exists()){ //判断文件是否存在
	                    InputStreamReader read = new InputStreamReader(
	                    new FileInputStream(file),encoding);//考虑到编码格式
	                    BufferedReader bufferedReader = new BufferedReader(read);
	                    String lineTxt = null;
	                    while((lineTxt = bufferedReader.readLine()) != null){
	                    	//System.out.println(lineTxt);
	                    	String s [] = lineTxt.split("\\.");
	                    	//System.out.println(s[0]);
	                    	if(s[0].length()<=4){
	                    		System.out.println(s[0]);
	                    	}
	                    }
	                    read.close();
	        }else{
	            System.out.println("找不到指定的文件");
	        }
	        } catch (Exception e) {
	            System.out.println("读取文件内容出错");
	            e.printStackTrace();
	        }
	     
	    }
	     
		public static void main(String[] args) {
			//System.out.println(("我123").length());
			//System.out.println(new String("我123").getBytes().length);
			// String filePath = "D:\\20170711.txt";
			//System.out.println(getImageStr("D:\\zl.png")); 
			ChargingJQ();
//		      "res/";
		       // readTxtFile(filePath);
		}

		public static String getImageStr(String imgFile) {  
	        InputStream in = null;  
	        byte[] data = null;  
	        try {  
	            in = new FileInputStream(imgFile);  
	            data = new byte[in.available()];  
	            in.read(data);  
	            in.close();  
	        } catch (FileNotFoundException e) {  
	            e.printStackTrace();  
	        } catch (IOException e) {  
	            e.printStackTrace();  
	        }  
	        return Base64.encodeBase64String(data);  
	    }  
	
		
		@Transactional(transactionManager = "o2oTransactionManager")
		public static void ChargingJQ() {

			
			AccountLog accountLog = new AccountLog();
			accountLog.setStartTime(new Date());
			accountLog.setId(UuidUtil.generateShortUuid());
			
			accountLog.setStatus("333");
			accountLog.setEndTime(new Date());
			accountLog.setRequestid("444");
			accountLog.setRequestPs("111111");
			accountLog.setResponsePs("2222222");
			
			accountLog.setLogType("ceshi");
			accountLog.setLoanapplyNo("5555");
			accountLog.setMethodname(Thread.currentThread().getStackTrace()[1].getMethodName());
			
			try {
				System.out.println("try");
				accountLog.setClassname("try");
				int a =1;
				a = a/0;
			} catch (Exception e) {
				System.out.println("catch");
				accountLog.setClassname("catch");
				//throw new RuntimeException();
				//return "退保证金（结清）失败";
			}finally{
				accountLogDao.insert(accountLog);
			}
		}	
		
}
